public class StaticTest {
    public static void main(String[] args) {

    }

    public static void main1(String[] args) {
        System.out.println(Student.returnClassRoom());

        // 静态成员变量可以直接通过类名访问
        Student s1 = new Student("zhang san","nan",18,90.0);
        Student s2 = new Student("li si","nv",18,80.0);
        Student s3 = new Student("wang wu","nan",20,78.0);

        // 也可以通过对象访问：但是classRoom是三个对象共享的
        System.out.println(s1.returnClassRoom());
        System.out.println(s2.returnClassRoom());
        System.out.println(s3.returnClassRoom());
    }
}

class Main{
    public static void main(String[] args) {
        { //直接使用{}定义，普通代码块
            int x = 10;
            System.out.println("x1 = " + x);
        }
        int x = 100;
        System.out.println("x2 = " + x);
    }
}

class Student{
    private String name;
    private String gender;
    private int age;
    private double score;
    private static String classRoom;

    //实例代码块
    {
        name = "zhao";
        gender = "男";
        age = 5;
        score = 60.0;
    }

    //静态代码块
    static {
        classRoom = "1401";
    }

    public static String returnClassRoom(){
        return classRoom;
    }

    Student(String name,String gender,int age,double score){
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.score = score;
    }
}